﻿using MVAScratchPad.Common;
using MVAScratchPad.Services;
using System.Threading.Tasks;

namespace MVAScratchPad.ViewModels
{
    public class SettingsViewModel : BaseViewModel
    {
        RelayCommand<object> _ResetCommand = null;
        public RelayCommand<object> ResetCommand
        {
            get
            {
                if (_ResetCommand != null)
                    return _ResetCommand;
                _ResetCommand = new RelayCommand<object>
                (
                    o => MessageBus.Instance.Send(new Models.ResetNotesMessage()),
                    () => true
                );
                this.PropertyChanged += (s, e) => _ResetCommand.RaiseCanExecuteChanged();
                return _ResetCommand;
            }
        }

        RelayCommand<object> _DeleteSearchHistoryCommand = null;
        public RelayCommand<object> DeleteSearchHistoryCommand
        {
            get
            {
                if (_DeleteSearchHistoryCommand != null)
                    return _DeleteSearchHistoryCommand;
                _DeleteSearchHistoryCommand = new RelayCommand<object>
                (
                    o => new Windows.ApplicationModel.Search.Core.SearchSuggestionManager().ClearHistory(),
                    () => true
                );
                this.PropertyChanged += (s, e) => _DeleteSearchHistoryCommand.RaiseCanExecuteChanged();
                return _DeleteSearchHistoryCommand;
            }
        }

        public override Task LoadState(Windows.UI.Xaml.Navigation.NavigationEventArgs m) { return null; }
        public override Task SaveState(Windows.UI.Xaml.Navigation.NavigationEventArgs m) { return null; }
    }
}